home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Apple Telecom / FaxWatch next >
Encoding:
Text File  |  1999-03-04  |  2.0 KB  |  122 lines  |  [TEXT/ToyS]

  1. property kasName : "FaxWatch"
  2. property kasFinder : "Finder"
  3.  
  4. property kasPrint : true -- Print incoming faxes?
  5.  
  6. global gasInfo
  7. global gasInfoLoc
  8. global gasLastStatus
  9.  
  10.  
  11. on run
  12.     set gasInfoLoc to {-1, -1}
  13.     set gasLastStatus to ""
  14.     
  15.     try
  16.         set gasInfoLoc to load preference named kasName
  17.     on error
  18.     end try
  19.     
  20.     set gasInfo to ¬
  21.         display info titled kasName ¬
  22.             located at gasInfoLoc
  23. end run
  24.  
  25.  
  26. on idle
  27.     ShowAction("Checking…")
  28.     
  29.     set n to FaxCheck()
  30.     
  31.     if (n > 0) then
  32.         ShowStatus("NEW FAXES: " & n, 15 * 32)
  33.         
  34.         if kasPrint then FaxPrint()
  35.     else
  36.         ShowStatus("Read my lips - no new faxes", 15 * 32 * 32)
  37.     end if
  38.     
  39.     ShowAction("Idle…")
  40.     
  41.     return 60 * 5
  42. end idle
  43.  
  44.  
  45. on ShowAction(act)
  46.     display info gasInfo ¬
  47.         message act ¬
  48.         with static state
  49. end ShowAction
  50.  
  51.  
  52. on ShowStatus(msg, col)
  53.     if (gasLastStatus is not msg) then
  54.         display info gasInfo ¬
  55.             message msg ¬
  56.             using color col ¬
  57.             using size 9 ¬
  58.             using font ¬
  59.             "Monaco" at line 2
  60.         
  61.         set gasLastStatus to msg
  62.     end if
  63. end ShowStatus
  64.  
  65.  
  66. on quit
  67.     ShowAction("Quitting…")
  68.     
  69.     set newLoc to screen location of ¬
  70.         (display info gasInfo with disposal)
  71.     
  72.     if (newLoc is not gasInfoLoc) then ¬
  73.         save preference newLoc named kasName
  74.     
  75.     continue quit
  76. end quit
  77.  
  78.  
  79. on FaxLaunch()
  80. end FaxLaunch
  81.  
  82.  
  83. on FaxCheck()
  84.     tell application "Apple Fax"
  85.         set n to number of faxes of unread faxes
  86.         set auto answer mode to true
  87.     end tell
  88.     
  89.     return n
  90. end FaxCheck
  91.  
  92.  
  93. on FaxPrint()
  94.     tell application "Apple Fax" to ¬
  95.         set numberReceived to number of faxes of unread faxes
  96.     
  97.     if (numberReceived > 0) then
  98.         tell application "Apple Fax"
  99.             activate
  100.             
  101.             set faxList to faxes of unread faxes as list
  102.             
  103.             -- Open each fax in the list and print it.
  104.             repeat with aFax in faxList
  105.                 set theFile to get the file of aFax
  106.                 open theFile
  107.                 try
  108.                     ignoring application responses
  109.                         print theFile
  110.                     end ignoring
  111.                 on error
  112.                     beep
  113.                 end try
  114.                 tell me to pause for 60 with seconds timing
  115.                 close the front window
  116.             end repeat
  117.         end tell
  118.         -- Quit "Apple Fax".
  119.         quit application "Apple Fax"
  120.     end if
  121. end FaxPrint
  122.